Skip to content

fix(slf): restore vanilla shadow lights when disabled#101

Merged
alandtse merged 2 commits into
devfrom
claude/objective-clarke-2b2ede
Jun 4, 2026
Merged

fix(slf): restore vanilla shadow lights when disabled#101
alandtse merged 2 commits into
devfrom
claude/objective-clarke-2b2ede

Conversation

@alandtse

@alandtse alandtse commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Problem

Fixes #97 — with Shadow Limit Fix unticked and the game restarted, all shadowcasters stop emitting light (both spots and omnis).

Disabling SLF at boot already skips every SCM game hook (Install early-returns), so the engine's shadow scheduler runs untouched. But the LightLimitFix cluster pipeline was not gated on SCM and still routed every shadow light through ShadowCasterManager::GetShadowSlot():

  • The scheduler hook never installed → the SCM pool (s_lights) stays empty → GetShadowSlot() returns -1 for every light.
  • UpdateLights() inserts each shadow light into shadowLightPtrs (marking it "handled"), then drops it on the stableSlot < 0 early-return; the activeLights fallback loop skips it too. Net: shadow-casting lights contribute zero to the cluster → blacked out.
  • CopyShadowLightData() shared the same dependency, leaving the Shadows (t102) buffer empty.

Fix

One central change — all three consumers (cluster builder, strict-light setup, shadow-data copy) route through GetShadowSlot():

  • ShadowCasterManager::IsActive() — boot-latched; true only when SCM installed its hooks at boot and no conflicting external plugin was detected.
  • GetShadowSlot() now falls back to the engine's own shadowmapDescriptors[0].shadowmapIndex when SCM is inactive — the exact vanilla slice the engine rendered into, with the directional sun mapped to -1. VR-aware (mirrors SetShadowParameters).

Result: with SLF off, point/spot casters light and shadow through the existing kSHADOWMAPS (t102/t103) path, exactly as vanilla LightLimitFix would — matching the issue's "no change from the game" intent. SCM-on behavior is unchanged. Downstream bounds checks already clamp any out-of-range slice safely.

Testing

  • Built ALL preset clean (0 compile/link errors), deployed to SE + VR.
  • Confirmed in-game (SE): with Shadow Limit Fix unticked, shadowcasters emit light again; toggling SLF back on leaves normal behavior unchanged.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 4, 2026 07:42
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alandtse, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 55 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 141dafda-454f-44b5-9fa5-372909172a5b

📥 Commits

Reviewing files that changed from the base of the PR and between 605f121 and f1ad17e.

📒 Files selected for processing (2)
  • src/Features/LightLimitFix/ShadowCasterManager.cpp
  • src/Features/LightLimitFix/ShadowCasterManager.h
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/objective-clarke-2b2ede

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores vanilla point/spot shadow-light behavior when Shadow Limit Fix (SCM) is disabled at boot by making ShadowCasterManager::GetShadowSlot() fall back to the engine’s own shadowmapDescriptors[0].shadowmapIndex instead of relying on the SCM pool (which is unpopulated when hooks aren’t installed). This prevents shadow-casting lights from being “handled then dropped” by downstream consumers that interpret -1 as “skip”.

Changes:

  • Added a boot-latched ShadowCasterManager::IsActive() API to express whether SCM hooks are actually live this session (enabled at boot + no external conflict).
  • Implemented an engine-descriptor-based fallback slot lookup (GetEngineShadowSlot) used when SCM is inactive.
  • Updated GetShadowSlot() to route through the fallback when SCM is inactive, preserving the existing -1 sentinel for directional/sun lights.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Features/LightLimitFix/ShadowCasterManager.h Documents and exposes IsActive() and clarifies GetShadowSlot() behavior when SCM is inactive.
src/Features/LightLimitFix/ShadowCasterManager.cpp Implements IsActive(), adds vanilla descriptor fallback slot resolution, and gates SCM pool lookup accordingly.

@alandtse alandtse changed the title fix(slf): restore vanilla shadow lights when SLF disabled at boot fix(slf): restore vanilla shadow lights when disabled Jun 4, 2026
alandtse and others added 2 commits June 4, 2026 07:58
Disabling Shadow Limit Fix at boot already skips every SCM game hook,
so the engine's shadow scheduler runs untouched. But the LightLimitFix
cluster pipeline was not gated on SCM and still routed every shadow
light through ShadowCasterManager::GetShadowSlot(). With the scheduler
hook never installed the SCM pool stays empty, so GetShadowSlot()
returned -1 for every light. UpdateLights() had already inserted each
light into shadowLightPtrs (marking it "handled"), then dropped it on
the -1 early-return, and the activeLights fallback skipped it too --
every shadow-casting light contributed zero to the cluster, blacking
out all shadowcasters (spots and omnis). CopyShadowLightData() shared
the same dependency, leaving the Shadows (t102) buffer empty.

Add ShadowCasterManager::IsActive() (boot-latched: true only when SCM
installed its hooks and no external conflict was detected) and make
GetShadowSlot() fall back to the engine's own
shadowmapDescriptors[0].shadowmapIndex when inactive -- the exact
vanilla slice the engine rendered into, with the directional sun
mapped to -1. All three consumers (cluster builder, strict-light
setup, shadow-data copy) route through GetShadowSlot(), so point/spot
casters now light and shadow exactly as vanilla LLF would without SLF.
SCM-on behavior is unchanged. Downstream bounds checks already clamp
any out-of-range slice safely.

Fixes #97

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Trim the IsActive / GetEngineShadowSlot / GetShadowSlot doc and inline
comments to concise "why" notes per the repo comment standard; no code
change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alandtse alandtse force-pushed the claude/objective-clarke-2b2ede branch from 22391ed to f1ad17e Compare June 4, 2026 07:58
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

No actionable suggestions for changed features.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse merged commit a54d884 into dev Jun 4, 2026
19 checks passed
@alandtse alandtse deleted the claude/objective-clarke-2b2ede branch June 4, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shadow limit fix: Disabling SLF breaks all shadowcasters

2 participants